from django.db.models import CharField, BooleanField
from main.models import BaseModel
from django.db import models


class Userapp(BaseModel):
    name = CharField("模型名称", max_length=100, blank=True, null=True)
    code = CharField("模型标识", max_length=100, blank=True, null=True)
    remark = CharField(max_length=200, blank=True, null=True)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = "Userapp"
        verbose_name_plural = verbose_name


class UserappFields(BaseModel):
    model = models.ForeignKey(
        Userapp,
        on_delete=models.PROTECT,
        verbose_name="model",
    )

    field_desc = CharField("字段描述", max_length=100, blank=True, null=True)
    field_name = CharField("字段标识", max_length=100, blank=True, null=True)
    field_type = CharField("字段类型", max_length=100, blank=True, null=True)
    field_length = CharField("字段长度", max_length=100, blank=True, null=True)
    field_default = CharField("字段默认值", max_length=100, blank=True, null=True)

    field_index = CharField("索引", max_length=100, blank=True, null=True)
    field_null = BooleanField("空", max_length=100, blank=True, null=True)

    field_remark = CharField("字段备注", max_length=100, blank=True, null=True)


    def __str__(self):
        return self.name

    class Meta:
        verbose_name = "UserappFields"
        verbose_name_plural = verbose_name
